<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<div id="stationInfoGrid"></div>
<div id="stationInfoToolbar">
	<div>
		<a href="#" class="easyui-linkbutton" onclick="stationInfo.toolbar.showSearchDialog();" data-options="
		iconCls:'icon-search',
		plain:true">
		  详情查看
		</a>
		<a href="#" class="easyui-linkbutton" onclick="stationInfo.toolbar.redo();" data-options="
		iconCls:'icon-redo',
		plain:true">
			取消
		</a>
	</div>
</div>
<div id="stationInfoSearchDialog" class="easyui-dialog ec-dialog" data-options="
title: '站内详细查看',
buttons: '#stationInfoSearchButtons',
iconCls:'icon-search',
closed: true,
onClose: stationInfo.toolbar.resetSearchFrom">
	<form id="stationInfoSearchForm" method="post">
		<p>
			<input type="text" name="title" class="easyui-textbox" data-options="label:'标题：'"  style="width: 300px">
		</p>
		<p>
			<input type="text" name="content" class="easyui-textbox" style="width: 300px;height:150px" data-options="label:'内容：',multiline:true">
		</p>
		<p>
			<input type="text" name="sendername" class="easyui-textbox" data-options="label:'发送者：'"  style="width: 300px">
		</p>
		<p>
			<input type="text" name="receivername" class="easyui-textbox" data-options="label:'发送角色：'"  style="width: 300px">
		</p>
		<p>
			<input type="text" name="send_time" class="easyui-textbox" data-options="label:'发送时间：'" style="width: 300px">
		</p>
		<p>
			<input type="text" name="expire_time" class="easyui-textbox" data-options="label:'过期时间：'" style="width: 300px">
		</p>
	</form>
</div>
<div id="stationInfoSearchButtons">
	<a href="#" onclick="stationInfo.toolbar.hiddenSearchDialog();" class="easyui-linkbutton" data-options="
	iconCls: 'icon-redo',
	plain: true">
		取消
	</a>
</div>
<script>	
	var stationInfo = {
		init : function() {
			stationInfo.stationInfoGrid = $('#stationInfoGrid');
			stationInfo.stationInfoSearchForm = $('#stationInfoSearchForm');
			stationInfo.stationSearchDialog = $('#stationSearchDialog');
			stationInfo.stationInfoGrid.datagrid({
			    url: '<%=request.getContextPath()%>/StuServlet?command=listStation',
			    fitColumns: true,
			    striped: true,
			    rownumbers: true,
			    pagination: true,
			    pageSize: 10,
			    pageList: [10, 20, 30, 40, 50],
			    pageNumber: 1,
			    toolbar: '#stationInfoToolbar',
			    columns:[[
					{field:'id', width:100, checkbox: true},
					{field:'title', title:' 标题', width:100, align:'center'},
					{field:'content', title:'内容', width:100, align:'center'},
					{field:'sendername', title:'发送者', width:100, align:'center'},
					{field:'receivername', title:'发送角色', width:100, align:'center'},
					{field:'send_time', title:'发送时间', width:100, align:'center'},
					{field:'expire_time', title:'过期时间', width:100, align:'center'}
			    ]],
				onDblClickRow: function(rowIndex, rowData) {
					stationInfo.toolbar.showSearchDialog(rowData.id);
				}
			});
		},
		toolbar: {
			redo: function() {
				stationInfo.stationInfoGrid.datagrid('unselectAll');
			},
			showSearchDialog:function(id){
				var getData = function(v)
				{
					$.post('<%=request.getContextPath()%>/StuServlet?command=listStationMinute', {id : v}, function(data) {
						if (data) {
							console.log(data)
							stationInfo.stationInfoSearchForm.form('load', {
								content: data.content,
								expire_time: data.expire_time,
								receivername: data.receivername,
								send_time: data.send_time,
								sendername: data.sendername,
								title: data.title
							});
							$('#stationInfoSearchDialog').dialog('open');
						} else {
							$.messager.alert('系统提示', '获取信息失败！', 'error')
						}
						$.messager.progress('close');
					}, 'json');
				}
				if (id) {
					getData(id);
				} else {
					var row = stationInfo.stationInfoGrid.datagrid('getSelections');
					if (row.length == 1) {
						getData(row[0].id);
					} else {
						$.messager.show({
							title: '系统提示',
							msg: '请选择一行数据进行查看！',
							timeout: 3000,
							showType: 'slide'
						});	
					}
				}
			},
			hiddenSearchDialog: function() {
				$('#stationInfoSearchDialog').dialog('close');
				stationInfo.toolbar.resetSearchFrom();
			},
			resetSearchFrom: function() {
				stationInfo.stationInfoSearchForm.form('reset');
			}
		}
	};
	
	$(function(){
		stationInfo.init();
	});
</script>